import { PureComponent } from "react";
import GrandSon from "./grandSon";
import AppContext from '../../context';

class Child extends PureComponent {
    constructor(props) {
        super(props);
    }

    static contextType = AppContext;

    counterIncrement = () => {
        const { increment } = this.props; 
        increment();
    }

    render() {
        const appContextValue = this.context; 
        return (
            <div className="border mt10">
                <p className="title">Class--Child</p>
                <button onClick={this.counterIncrement}>Counter里面的++++</button>
                <h3>{JSON.stringify(appContextValue)}</h3>
                <GrandSon></GrandSon>
            </div>
        )
    }
}

export default Child;